#include <time.h>
#include "ueib.h"

#define DBFILE "meters.db"

int initialise_meters(char *fname);
void list_meters();
int open_iocard(int cardno);
int close_iocard();

typedef struct {
  int id;                // The database unique identifier number of this meter.
  char description[20];  // string describing the parameter being measured.
  char unit[10];          // string describing the metered units.
  double cfac;            // Conversion factor to convert from meter counts to 
                          // engineering units.  value = cfac x counts
  time_t output_period;   // period (in seconds between writing data to the output database
  int iocard;             // Number of the io card to be used for this meter 
                         //  (not used).
  int input;             // number of the digital input on the card for this meter
  int lastval;           // the value of the input the last time it was polled.

  double reading;         // the current meter reading

  time_t last_output;     // the system time when data was last written to the output database
} meterinfo;


/* The table of meters to monitor */
#define MAXMETER 5
extern int n_meter;
extern meterinfo meters[];

/* The file handle to access the iocard */
extern ueib_handle *uh;

/* flag to say whether or not this process is a daemon */
extern int daemonf;
